<!DOCTYPE html>
<html class="um landscape min-width-240px min-width-320px min-width-480px min-width-768px min-width-1024px">
<head>
<title></title>
<meta charset="utf-8">
<meta name="viewport" content="target-densitydpi=device-dpi, width=device-width, initial-scale=1, user-scalable=no, minimum-scale=1.0, maximum-scale=1.0">
<meta name="copyright" content="http://www.appcms.org" />
<link rel="stylesheet" href="skin/base.css">
<link rel="stylesheet" href="skin/comment.css">
<script src="js/zy_control.js"></script>
<script src="js/zy_click.js"></script>
<script src="js/config.js"></script>
<script src="js/common.js"></script>
</head>
<body ontouchstart>
<div class="box-ver box">
  
  <div id="header">
  	<div class="title">
  		<span class="l icon back" ontouchstart="zy_touch('act')" onclick="uexWindow.close(-1);"></span>
		<span class="txt">转发分享</span>
		<span class="r" ontouchstart="zy_touch('act')" onclick="postdata();">提交</span>
	</div>
  </div>
  
  <div id="content">
    <div class="textareadiv">
      <textarea id="text" name="text" maxlength="240" placeholder="请填写分享内容~" onkeypress="getRealLen(this.value);" oninput="getRealLen(this.value);"></textarea>
      <em id="words">240</em> </div>
  </div>
  <div id="share">
    <div id="sina" onclick="pick('sina')">
      <em></em>
    </div>
    <div id="qqweibo" onclick="pick('qqweibo')">
      <em></em>
    </div>
    <!--<center id="qzone" onclick="pick('qzone')"><em></em></center>--> 
  </div>
</div>
</body>
<script>
    	zy_init();
		var Sele = {'sina':false,'qzone':false,'qqweibo':false};
		var strlen=0;
		
		function pick(t){
			if (localStorage[t + '_connectid']) {
				if (Sele[t] == true) {
					$$(t).className = '';
					Sele[t] = false;
				}else{
					$$(t).className = 'tie';
					Sele[t] = true;
				}
			}else{
				uexWindow.alert('未绑定分享平台','请先绑定分享账号','关闭');
				uexWindow.open('user_bind', '0', 'user_bind.html', 4, '', '', 0);
			}
		}
		
		function getRealLen(str){
    		strlen=str.replace(/[^\x00-\xff]/g,'__').length;
			$$('words').innerHTML=int(240-strlen);
			$$('text').value=substr(str,240);
		}
		
		function postdata(){
			if (c_l()) {
				if(!Sele['sina']&&!Sele['qzone']&&!Sele['qqweibo']){
					uexWindow.alert('未选择分享平台','请选择要分享的平台','关闭');
					return false;
				}
				
				var text=trim($$('text').value);
				
				if(text.length>240){
					uexWindow.alert('','分享内容超出240字节','关闭');return false;
				}else if(text.length<8){
					uexWindow.alert('','分享内容不能少于8字节','关闭');return false;
				}
				
				uexWindow.toast(1, 5, '分享提交中...', 0);
				var url = app_path+'index.php?m=iappShare&c=index&a=add';
				uexXmlHttpMgr.open(-1,'post',url,"8000");
				uexXmlHttpMgr.setPostData(-1,'0','userid',localStorage['u_id']);
				uexXmlHttpMgr.setPostData(-1,'0','acctoken',localStorage['u_acctoken']);
				uexXmlHttpMgr.setPostData(-1,'0','text',text);
				
				for(var item in Sele){
					if(Sele[item]){				
						uexXmlHttpMgr.setPostData(-1,'0',item,'true');
					}
				}			
				uexXmlHttpMgr.send(-1);
			}else{
				gologin();	
			}
		}
		
		
		window.uexOnload=function(type){
			if(!type){
				uexXmlHttpMgr.onData = function(opId, status, data){
					uexXmlHttpMgr.close(opId);
					uexWindow.closeToast();
					if (status == 1) {
						data = JSON.parse(data);
						if(data['success']=='OK'){
							uexWindow.evaluatePopoverScript(localStorage['p_type'],'content','ok(\'分享成功\')');
							uexWindow.close(-1);
						}else if (data['success'] == 'NOTLOGIN') {
							localStorage['login'] = 'share';
							uexWindow.open('login', '0', 'login.html', 11, '', '', 0);
						}else{
							uexWindow.alert('', data['msg'], '关闭');
						}
					}else if (status == -1) {
						uexWindow.alert('', '分享提交超时', '关闭');
					}
				}
				
				$$('text').value=localStorage['p_title']+' '+localStorage['p_url'];
			}
		}
    </script>
</html>